import java.util.HashMap;
import java.util.Map;

/**
 * @author LKQ
 * @date 2022/3/5 15:53
 * @description
 */
public class Solution {
    public static void main(String[] args) {

    }
    public boolean hasGroupsSizeX(int[] deck) {
        int[] count = new int[10000];
        for (int c: deck) {
            count[c]++;
        }

        int g = -1;
        for (int i = 0; i < 10000; ++i) {
            if (count[i] > 0) {
                if (g == -1) {
                    g = count[i];
                } else {
                    // 求最大公约数
                    g = gcd(g, count[i]);
                }
            }
        }
        return g >= 2;
    }

    public int gcd(int x, int y) {
        // 求最大公约数函数
        return x == 0 ? y : gcd(y % x, x);
    }
}
